package com.enzoism.springboot.dive.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(urlPatterns = "/*", filterName = "logFilter2")
public class LogCostFilter2 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("------>LogCostFilter2-进行Filter初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        long start = System.currentTimeMillis();
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("---->LogCostFilter2请求进入到过滤器，耗时(ms)："+(System.currentTimeMillis()-start));
    }

    @Override
    public void destroy() {
        System.out.println("------>LogCostFilter2-进行Filter销毁");
    }
}
